# write by hasaki
# first edit on 2019/03/22
# last change on 2019/03/27
# 直接运行，即可进行gateio交易所的量化，该脚本从run2.py分化出来
import sys
import os
sys.path.append(os.getcwd())


def gateGatewayTest():
    '''测试gateio网关'''
    from hashakisea.api.digital.gateGateway import GateGateway

    a=GateGateway()
    a.start()
    a.run()

def tradeTest():
    '''检测交易引擎'''
    from hashakisea.engine.trade.tradeEngine import MainEngine
    from hashakisea.strategy.haStrategy_test import HaStrategyTest
    from hashakisea.strategy.haStrategy_trade import TickStrategy
    from hashakisea.strategy.haStrategy_1min_test import HaBarTest
    
    a=MainEngine()
    a.engingSetting('127.0.0.1',6666)
    a.accountSimulate(3000,0)              # 模拟交易的时候使用的账户资产设置
    a.start()
    s=HaStrategyTest()
    t=TickStrategy()
    b=HaBarTest()
    strategy=[{'test_strategy':['depth',s]},{'tick strategy':['tick',t]},{'bar strategy':['bar',b]}]
    a.strategyIn(strategy)
    a.run()

def bigStrategyTest():
    '''包含大策略的测试'''
    from hashakisea.strategy.bigStrategy.haBigStrategy import BigStrategy
    a=BigStrategy()
    a.settingSocket('127.0.0.1',6667)
    a.run()

if __name__=='__main__':
    from multiprocessing import Process
    from time import sleep
    get_data_process=Process(target=gateGatewayTest)
    run_trade=Process(target=tradeTest)
    big_strategy=Process(target=bigStrategyTest)
    get_data_process.start()
    sleep(0.5)
    run_trade.start()
    big_strategy.start()